﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

class WaterCannonScript : EnhancementBlock
{
    AnimationCurve animationCurve;

    bool StrengthSliderValueSign = false;

    public override void SafeAwake()
    {
#if DEBUG
        Debug.Log("水炮添加摇杆");
#endif
    }

    WaterCannonController waterCannonController;
    public override void OnSimulateStart_EnhancementEnabled()
    {
        waterCannonController = GetComponent<WaterCannonController>();

        //animationCurve = new AnimationCurve(new Keyframe[] { new Keyframe(0f + joyAxis.Offset, 0f), new Keyframe(1f*joyAxis.Max , waterCannonController.StrengthSlider.Value) });

        StrengthSliderValueSign = Tool.FloatToBool(waterCannonController.StrengthSlider.Value);
    }
    float targetStrength = 0f;
    public override void SimulateUpdateAlways_EnhancementEnable()
    {
        if (StrengthSliderValueSign)
        {
            waterCannonController.isActive =Tool.FloatToBool(joyAxis.Value_Direction);
        }

        var value = 0f;
        if (LerpToggle.IsActive)
        {
            value = Mathf.MoveTowards(targetStrength,/* animationCurve.Evaluate(*/joyAxis.Value/*)*/, LerpSpeedSlider.Value/* * Mathf.Pow(10, (waterCannonController.StrengthSlider.Value.ToString().Length - 1))*/);
        }
        else
        {
            value =/* animationCurve.Evaluate(*/joyAxis.Value/*)*/;
        }
        targetStrength = value;

        waterCannonController.StrengthSlider.Value = targetStrength;
        waterCannonController.ParentMachine.RegisterFixedUpdate(waterCannonController, false);
    }

}

